import request from '@/utils/request'
import type { ResponseData } from '@/types/common'
import type { Banner, CreateBannerDto, UpdateBannerDto } from '@/types/banner'

// 获取 Banner 列表
export const getBannerList = () => {
  return request.get<{
    code: number
    data: {
      items: Banner[]
      total: number
    }
    message: string
  }>('/banners/list')
}

// 创建 Banner
export const createBanner = (data: CreateBannerDto) => {
  return request.post<ResponseData>('/banners', data)
}

// 更新 Banner
export const updateBanner = (id: number, data: UpdateBannerDto) => {
  return request.patch<ResponseData>(`/banners/${id}`, data)
}

// 更新 Banner 状态
export const updateBannerStatus = (id: number) => {
  return request.patch<ResponseData>(`/banners/${id}/status`)
}

// 删除 Banner
export const deleteBanner = (id: number) => {
  return request.delete<ResponseData>(`/banners/${id}`)
}
